<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <!--{include file='comm/header.tpl'}-->
    <title>商品详情</title>
    <!--{include file='comm/comm_editor.tpl'}-->
    <style>
        html{
            overflow-y:scroll;
            overflow:-moz-scrollbars-vertical;
        }

        .detailTable{
            border:1px solid #D4C6C6;
            border-collapse: collapse;
        }
        .title_td{
            background:#A5CBBD;
            border:1px solid #BCB4B7;
            padding:5px 0 5px 5px;
        }

        .msg_td{
            border:1px solid #BCB4B7;
            padding:5px 0 5px 5px;
        }

    </style>
</head>

<body>
<div class="select-box">
    <div onclick="goods.change(1);" id="select_1">
        商品基本信息
    </div>
    <div onclick="goods.change(2);" id="select_2">
        商品SKU
    </div>
    <div onclick="goods.change(3);" id="select_3">
        图片和描述
    </div>
    <div onclick="goods.change(4);" id="select_4">
        商品关键字
    </div>
    <div onclick="goods.change(5);" id="select_5">
        商品标签
    </div>
</div>
<div style="width:100%">
<!--{ if $goodsInfo->index == 1}-->
<div class="items clearfix">
    <h2 style="" class="tal">商品基本信息</h2>
    <div class="items2">
    <!--{if $error_msg}-->
        <div class="error-box">
            <!--{$error_msg}-->
        </div>
        <!--{else}-->
    <div>
    <table class="comm_edit_table" style="width:950px;">
    <tr style="height:30px;">
        <td style="text-align:right;width:10%;" class="td_title">商品编码：</td>
        <td style="width:55%;">
            <!--{$goodsInfo->product_code}-->
        </td>
    <td rowspan="6">
    <div style="width:240px;height:240px;margin:0px auto;">
        <!--{ if $goodsInfo->goodsMainPic != ''}-->
        <img class="bigImgCss"  src="/quanliadmin/docroot/images/goods/<!--{$goodsInfo->goodsMainPic}-->" />
            <!--{/if}-->
    </div>
    </td>
    </tr>
        <tr style="height:30px;">
            <td style="text-align:right;" class="td_title">商品名称：</td>
            <td>
                <input type="text" name="goodsName" id="goodsName" value="<!--{$goodsInfo->goodsName}-->" style="width:500px;">
            </td>
        </tr>
        <tr style="height:30px;">
            <td style="text-align:right" class="td_title">商品分类：</td>
            <td style="text-align:left">

                <select style="width:100px;" id="bigCategoryID" name="bigCategoryID">
                    <option value="0">请选择</option>
                        <!--{foreach from=$bigCategory item=big}-->
                    <option value="<!--{$big->bigCategoryID}-->" <!--{if $goodsInfo->bigCategoryID == $big->bigCategoryID }--> selected <!--{/if}--> ><!--{$big->description}--></option>
                        <!--{/foreach}-->
                </select>

                <select style="width:100px;" id="middleCategoryID" name="middleCategoryID">
                    <option value="0">请选择</option>
                        <!--{foreach from=$middleCategory item=middle}-->
                    <option value="<!--{$middle->midCategoryID}-->" <!--{if $goodsInfo->middleCategoryID == $middle->midCategoryID }--> selected <!--{/if}--> ><!--{$middle->description}--></option>
                        <!--{/foreach}-->
                </select>

                <select style="width:150px;" id="smallCategoryID" name="smallCategoryID">
                    <option value="0">请选择</option>
                        <!--{foreach from=$smallCategory item=small}-->
                    <option value="<!--{$small->smallCategoryID}-->" <!--{if $goodsInfo->smallCategoryID == $small->smallCategoryID }--> selected <!--{/if}--> ><!--{$small->description}--></option>
                        <!--{/foreach}-->
                </select>

            </td>
        </tr>
        <tr style="height:30px;">
            <td style="text-align:right;" class="td_title">商品品牌：</td>
            <td>
                <select style="width:100px;" id="brandID" name="brandID">
                    <option value="0">请选择</option>
                        <!--{foreach from=$brand_data item=b_l}-->
                    <option value="<!--{$b_l->brandID}-->" <!--{if $goodsInfo->brandID == $b_l->brandID }--> selected <!--{/if}--> ><!--{$b_l->brandName}--></option>
                        <!--{/foreach}-->
                </select>
            </td>
        </tr>
        <tr style="height:30px;">
            <td style="text-align:right;" class="td_title">商品单位：</td>
            <td>
                <select style="width:80px;" id="unitID" name="unitID">
                    <option value="0">请选择</option>
                        <!--{foreach from=$goods_unit item=unit}-->
                    <option value="<!--{$unit->unitID}-->" <!--{if $goodsInfo->unitID == $unit->unitID }--> selected <!--{/if}--> ><!--{$unit->unitName}--></option>
                        <!--{/foreach}-->
                </select>
            </td>
        </tr>
        <tr style="height:80px;">
            <td style="text-align:right" class="td_title">商品简述：</td>
            <td>
                <textarea id="brief" name="brief" style="width:500px;height:60px; font-size:12px;" style="ime-mode:active;" autocomplete="off"><!--{$goodsInfo->brief}--></textarea>
            </td>
        </tr>
        <tr style="height:80px;">
            <td style="text-align:right" class="td_title">商品备注：</td>
            <td>
                <textarea id="memo" name="memo" style="width:500px;height:60px; font-size:12px;" style="ime-mode:active;" autocomplete="off"><!--{$goodsInfo->memo}--></textarea>
            </td>
        </tr>
    </table>
    </div>
        <!--{/if}-->
    </div>
</div>
<div class="items clearfix">
    <h2 style="" class="tal">商品价格信息</h2>
    <div style="float:right;margin-top:-22px;margin-right:20px;">
        <a href="javascript:void(0);" onclick="open_changePrice();">调价</a>
    </div>
    <div style="clear:left;"></div>
    <div class="items2">
        <div>
            <table class="comm_edit_table" style="width:950px;">
                <tr style="height:30px;">
                    <td style="text-align:right;width:10%;" class="td_title">吊牌价：</td>
                    <td style="width:30%;">
                        <!--{$goodsInfo->marketPrice}-->
                    </td>
                    <td style="width:15%;text-align:right;">销售价：</td>
                    <td><!--{$goodsInfo->salePrice}--></td>
                </tr>
                <tr style="height:30px;">
                    <td style="text-align:right;" class="td_title">积分兑换：</td>
                    <td>
                    <!--{if $goodsInfo->pointsByFlg == 1}-->是<!--{else}-->否<!--{/if}-->
                    </td>
                    <td style="width:15%;text-align:right;">兑换积分：</td>
                    <td><!--{$goodsInfo->addPoints}--></td>
                </tr>
                <tr style="height:30px;">
                    <td style="text-align:right;" class="td_title">兑换金额：</td>
                    <td>
                        <!--{$goodsInfo->pointPrice}-->
                    </td>
                    <td style="width:15%;text-align:right;">赠送积分：</td>
                    <td><!--{$goodsInfo->salePoints}--></td>
                </tr>

                <tr style="height:30px;">
                    <td style="text-align:right;" class="td_title">等级优惠：</td>
                    <td>
                        全不不享受折扣   <a href="javascript:void(0);" onclick="open_editLevel();">编辑等级折扣</a>
                    </td>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        </div>
    </div>
</div>
<!--{elseif $goodsInfo->index == 2}-->

<table id="flex" style="display:none;"></table>

<!--{elseif $goodsInfo->index == 3}-->

<div class="items clearfix">
    <h2 style="" class="tal">展示图片</h2>
    <div class="items2">

        <table>
            <tr>
                <td style="width:20%;">
                    <div style="width:100%;">
                        <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
                            <img src="" id="img_1" style="width:100%;height:100%;" >
                        </div>
                        <div style="padding-top:5px;text-align: center;">
                            <input type="button" class="btn" value="删除" onclick="">&nbsp;
                            <input type="button" class="btn" value="上传" onclick="goods.uploadPic(1);">
                            <input type="hidden" value="" name="hidImg_1" value="<!--{$pic->pictureSrc}-->">
                        </div>
                    </div>
                </td>
                <td style="width:20%;padding-left: 20px;">
                    <div style="width:100%;">
                        <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
                            <img src="" id="img_2" style="width:100%;height:100%;" >
                        </div>
                        <div style="padding-top:5px;text-align: center;">
                            <input type="button" class="btn" value="删除" onclick="">&nbsp;
                            <input type="button" class="btn" value="上传" onclick="goods.uploadPic(2);">
                            <input type="hidden" value="" name="hidImg_2" >
                        </div>
                    </div>
                </td>
                <td style="width:20%;padding-left: 20px;">
                    <div style="width:100%;">
                        <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
                            <img src="" id="img_3" style="width:100%;height:100%;" >
                        </div>
                        <div style="padding-top:5px;text-align: center;">
                            <input type="button" class="btn" value="删除" onclick="">&nbsp;
                            <input type="button" class="btn" value="上传" onclick="goods.uploadPic(3);">
                            <input type="hidden" value="" name="hidImg_3" >
                        </div>
                    </div>
                </td>
                <td style="width:20%;padding-left: 20px;">
                    <div style="width:100%;">
                        <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
                            <img src="" id="img_4" style="width:100%;height:100%;" >
                        </div>
                        <div style="padding-top:5px;text-align: center;">
                            <input type="button" class="btn" value="删除" onclick="">&nbsp;
                            <input type="button" class="btn" value="上传" onclick="goods.uploadPic(4);">
                            <input type="hidden" value="" name="hidImg_4" >
                        </div>
                    </div>
                </td>
                <td style="width:20%;padding-left: 20px;">
                    <div style="width:100%;">
                        <div style="width:100%;height:130px;border:1px solid #E2D9D9;">
                            <img src="" id="img_5" style="width:100%;height:100%;" >
                        </div>
                        <div style="padding-top:5px;text-align: center;">
                            <input type="button" class="btn" value="删除" onclick="">&nbsp;
                            <input type="button" class="btn" value="上传" onclick="goods.uploadPic(5);">
                            <input type="hidden" value="" name="hidImg_5" >
                        </div>
                    </div>
                </td>
            </tr>
        </table>

    </div>
</div>

<div class="items clearfix">
    <h2 style="" class="tal">详细描述</h2>
    <div class="items2">
        <div>
            <textarea name="description" id="description" style="width:100%;height:400px;visibility:hidden;"><!--{$goodsInfo->description}--></textarea>
        </div>
    </div>
</div>

<!--{elseif $goodsInfo->index == 4}-->

<table class="comm_edit_table" style="width:950px;">
    <tr style="height:30px;">
        <td style="text-align:right;width:200px;">关键词：</td>
        <td>
            <input type="text" name="keyWord" id="keyWord" value="" style="width:200px;">
            &nbsp;
            <input type="button" value="添加" onclick="addKeyWords();">
        </td>
    </tr>
    <tr style="height:30px;">
        <td style="text-align:right;width:200px;" >添加的关键词：</td>
        <td>
            <div id="keywordList" style="width:500px;word-wrap: break-word;"></div>
        </td>
    </tr>
</table>

<!--{elseif $goodsInfo->index == 5}-->

<!--{/if}-->

<!--------------------------------------------------------------  调价弹出层 start  ------------------------------------------------------------>

<div id="hiddenLayer" style="display:none;width: 100%;height: 100%;top: 0;position: fixed;z-index: 1000;">
    <div style="width:350px;margin:100px auto;border:1px solid #9B9898;background: #FCF9F9;">
        <form name="changePrice" id="changePrice">
            <table class="detailTable" style="width:100%;">
                <tr>
                    <td style="height:30px;background:#F7EFEF;text-align:left;padding-left:10px;font-weight: bold;font-size:15px;" >
                        调价
                    </td>
                    <td style="text-align: right;padding-right:10px;background:#F7EFEF;">
                        <a href="javascript:void(0);" onclick="close_changePrice();">[关闭]</a>
                    </td>
                </tr>
                <tr>
                    <td class="title_td" style="text-align:right;width:40%;" class="td_title">吊牌价：</td>
                    <td class="msg_td" style="text-align:left;" >
                        <input type="text" name="marketPrice" id="marketPrice" value="<!--{$goodsInfo->marketPrice}-->" style="width:90%;">
                    </td>
                </tr>
                <tr>
                    <td class="title_td" style="text-align:right;">销售价：</td>
                    <td class="msg_td" style="text-align:left;">
                        <input type="text" name="salePrice" id="salePrice" value="<!--{$goodsInfo->salePrice}-->" style="width:90%;" >
                    </td>
                </tr>
                <tr>
                    <td class="title_td" style="text-align:right;">积分兑换：</td>
                    <td class="msg_td" style="text-align:left;">
                        <input type="radio" name='pointsByFlg' value="1" <!--{if $goodsInfo->pointsByFlg == 1}--> checked <!--{/if}--> >是
                        <input type="radio" name='pointsByFlg' value="0" <!--{if $goodsInfo->pointsByFlg == 0}--> checked <!--{/if}--> >否
                    </td>
                </tr>
                <tr>
                    <td class="title_td" style="text-align:right;">兑换积分：</td>
                    <td class="msg_td" style="text-align:left;">
                        <input type="text" name="addPoints" id="addPoints" value="<!--{$goodsInfo->addPoints}-->" style="width:90%;" >
                    </td>
                </tr>
                <tr>
                    <td class="title_td" style="text-align:right;">兑换金额：</td>
                    <td class="msg_td" style="text-align:left;">
                        <input type="text" name="pointPrice" id="pointPrice" value="<!--{$goodsInfo->pointPrice}-->" style="width:90%;" >
                    </td>
                </tr>
                <tr>
                    <td class="title_td" style="text-align:right;">赠送积分：</td>
                    <td class="msg_td" style="text-align:left;">
                        <input type="text" name="salePoints" id="salePoints" value="<!--{$goodsInfo->salePoints}-->" style="width:90%;" >
                    </td>
                </tr>
                <tr>
                    <td class="msg_td" style="text-align:center;" colspan="2" >
                        <input type="button" class="btn" onclick="" value="保存" />
                        <input type="button" class="btn" onclick="close_changePrice();" value="关闭" />
                        <input type="hidden" value="<!--{$goodsInfo->postID}-->" />
                    </td>
                </tr>
            </table>
        </form>
    </div>

</div>
<!--------------------------------------------------------------  调价弹出层 end ------------------------------------------------------------>

<!--------------------------------------------------------------  等级折扣出层 start  ------------------------------------------------------------>

<div id="hiddenLevel" style="display:none;width: 100%;height: 100%;top: 0;position: fixed;z-index: 1000;">
    <div style="width:450px;margin:200px auto;border:1px solid #9B9898;background: #FCF9F9;">
        <table class="detailTable" style="width:100%;">
            <tr>
                <td style="height:30px;background:#BCB4B7;text-align:left;padding-left:10px;font-weight: bold;font-size:15px;" >
                    等级优惠
                </td>
                <td style="text-align: right;padding-right:10px;background:#BCB4B7;">
                    <a href="javascript:void(0);" onclick="close_editLevel();">[关闭]</a>
                </td>
            </tr>
            <tr>
                <td style="height:50px;">
                    &nbsp;&nbsp;
                    <input type="radio" name="changeLevel" value="1" />全部是&nbsp;&nbsp;
                    <input type="radio" name="changeLevel" value="2" />全部否&nbsp;&nbsp;
                    <input type="radio" name="changeLevel" value="3" />部分
                </td>
            </tr>
            <tr>
                <td style="height:40px;word-wrap: break-word;">
                <!--{foreach from=$cust_rank item=rank}-->
                    <input type="checkbox" name="level" id="<!--{$rank->rankID}-->" value="<!--{$rank->rankID}-->"><!--{$rank->rankName}--> &nbsp;&nbsp;
                        <!--{/foreach}-->
                </td>
            </tr>
            <tr>
                <td class="msg_td" style="text-align:center;" colspan="2" >
                    <input type="button" class="btn" onclick="" value="保存" />
                    <input type="button" class="btn" onclick="close_editLevel();" value="关闭" />
                </td>
            </tr>
        </table>

    </div>

</div>
<!--------------------------------------------------------------  等级折扣弹出层 end ------------------------------------------------------------>

<div class="bottom_fixbox">
    <div class="rectbox tac">
        <input type="button" class="btn" onclick="" value="保存" />
        <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
    </div>
</div>

</div>
</body>
</html>
<script type="text/javascript">
    $(document).ready(function(){
        $('#select_<!--{$goodsInfo->index}-->').addClass('selected');
    });

    var postID = '<!--{$goodsInfo->postID}-->';

    $("#flex").flexigrid({
        url:"/invokingAjax-backend/goods/goodsUnreleased.ajax?operFlg=3&twoPostID=<!--{$goodsInfo->postID}-->",
        dataType: "json",
        colModel : [
        {display: "商品SKU",  width : 100},
        {display: "商品名称", width : 350},
        {display: "商品规格", width : 100},
        {display: "吊牌价格", width : 65},
        {display: "销售价格", width : 65},
        {display: "积分价格", width : 60},
        {display: "赠送积分", width : 60},
        {display: "库存标志", width : 60,align:"center"}
        ],
        sortname: "",
        sortorder: "",
        rp: 30,
        useRp: true,
        showTableToggleBtn: true
    });

    var goods = {
        change: function(index){
            window.location.href = '/quanliadmin/app/goods/goodsEdit.pscript?operFlg=2&postID=<!--{$goodsInfo->postID}-->&index='+index;
        },

        //上传图片
        uploadPic:function( flg ){
            E.open("/quanliadmin/app/goods/goodsEdit.pscript?operFlg=3&postID=<!--{$goodsInfo->postID}-->&flg=" + flg, "上传", {height: 400,width: 700, top: 50, left: 150});
        },

        //显示图片
        showImage:function( imageUrl , flg ){
            $('img_' + flg).attr('src', imageUrl);
            $('hidImg_' + flg).val(imageUrl);
        },

        addList:function( obj ){

            if( obj.code == 200 ){

                var params = obj.data;

                var html = '<option value="">请选择</option>';

                for(var i=0; i<params.length; i++){
                    html += '<option value="' + params[i].id + '">' + params[i].name + '</option>';
                }

                if( Flg == 1 ){
                    $("#middleCategoryID").html(html);
                }else if ( Flg == 2 ){
                    $("#smallCategoryID").html(html);
                }

            }else{
                E.alert('系统错误，请与管理员联系');
            }

        }

    }

    //变更大分类，查询中分类
    $("#bigCategoryID").change(function(){

        //获取当前选中的省份ID
        var bigCategoryID = $(this).val();

        Flg = 1;

        //将小分类置空
        $("#smallCategoryID").html('<option value="">请选择</option>');

        jquery_ajax(2,{bigCategoryID:bigCategoryID,flg:1},goods.addList);
    })

    //变更中分类，查询小分类
    $("#middleCategoryID").change(function(){

        //获取当前选中的大分类和中分类
        var bigCategoryID    = $("#bigCategoryID").val();
        var middleCategoryID = $(this).val();

        Flg = 2;

        jquery_ajax(2,{bigCategoryID:bigCategoryID,middleCategoryID:middleCategoryID,flg:2},goods.addList);
    })

    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/goods/goodsUnreleased.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }

    //打开调价弹出层
    function open_changePrice(){
        $("#hiddenLayer").show();
    }

    //关闭调价弹出层
    function close_changePrice(){
        $("#hiddenLayer").hide();
    }

    //打开调价弹出层
    function open_editLevel(){
        $("#hiddenLevel").show();
    }

    //关闭调价弹出层
    function close_editLevel(){
        $("#hiddenLevel").hide();
        $("input[name='level']").each(function(){
            var id = $(this).attr('id');
            document.getElementById(id).checked = false;
            document.getElementById(id).disabled = false;
        })
        $("input[name='changeLevel']").each(function(){
            $(this).removeAttr('checked');
        })

    }

    //优惠条件选择
    $("input[name='changeLevel']").click(function(){
        var value = $(this).val();
        if( value == 1 ){

            $("input[name='level']").each(function(){
                var id = $(this).attr('id');
                document.getElementById(id).checked = true;
                document.getElementById(id).disabled = true;
            })

        }else if ( value == 2 ){

            $("input[name='level']").each(function(){
                var id = $(this).attr('id');
                document.getElementById(id).checked = false;
                document.getElementById(id).disabled = true;
            })

        }else if ( value == 3 ){

            $("input[name='level']").each(function(){
                var id = $(this).attr('id');
                document.getElementById(id).checked = false;
                document.getElementById(id).disabled = false;
            })

        }

    })

    //添加关键词
    function addKeyWords(){
        var keyWord = $("#keyWord").val();

        if( keyWord == '' ){
            E.alert('请输入关键词');
            return false;
        }

        //校验加入的关键字是否已经添加
        var exist = false;

        if( $("#keywordList").html() != '' ){

            $("input[name='addedKeywords']").each(function(){

                var objValue = $(this).val();

                if( objValue == keyWord ){
                    E.alert('关键词[' + keyWord + ']重复添加');
                    exist = true;
                }
            })

        }

        if( !exist ){
            document.getElementById('keywordList').innerHTML += '&nbsp;&nbsp;<input type="checkbox" checked name="addedKeywords" value="' + keyWord + '">' + keyWord;
        }

    }

</script>